// 2025/11/6
// 多数元素

class Solution {
public:
    int majorityElement(vector<int>& nums) {
        int cur = -1, count = 0, n = nums.size();
        for(int i = 0; i < n; i++)
        {
            if(count == 0)
            {
                cur = nums[i];
                count++;
            }
            else if(nums[i] == cur)
            {
                count++;
            }
            else
            {
                count--;
            }
        }
        return cur;
    }
};